const http = require("http");
// 引入自定义路由对象
const router = require("./route");

function serverStart() {
  let server = http.createServer();
  server.on("request", (req, res) => {
    try {
      // router[req.url](res);
      router[req.url](res);
    } catch {
      router["/404"](res);
    }
  });

  server.listen(3000, () => {
    console.log("成功启动3000端口");
  });
}

module.exports = serverStart;
